var TutorStudentEvaYzx = app.controller('TutorStudentEvaYzx', function($rootScope,$stateParams, $scope, $http,$state,$timeout,$cordovaDevice,$cordovaChat,TutorStudentEvaYzxData) {
	try{
		$rootScope.showf=false;
		$scope.busy = false;
		
		$scope.currentPage = 1;
		$scope.limit = 10;
		$scope.pages = 1;
		
		$scope.list={};
		var url=SITE_URL+"index.php?app=baseloginapp&act=studentevayzx&callback=JSON_CALLBACK";
		$http.jsonp(url).success( function(data) {
			if(data.done){
				$scope.list=data.retval.data;
				$scope.pages = Math.ceil(data.retval.total
						/ $scope.limit);
				$scope.busy = false;
			}
		});	
		
		$scope.closeAlert = function(index) {
			$scope.alerts.splice(index, 1)
		}
		
		
		//加载更多
		$scope.loadMore = function() {
			if ($scope.currentPage < $scope.pages) {
				if ($scope.busy) {
					return false;
				}
				$scope.busy = true;
				$scope.currentPage++;
				var url = SITE_URL
				+ "index.php?app=baseloginapp&act=studentevayzx&callback=JSON_CALLBACK"+"&page="+$scope.currentPage;
				$http.jsonp(url).success(
						function(data) {
							if (data.done) {
								for ( var i in data.retval.data) {
									if (typeof data.retval.data[i] != "function")
										$scope.list.push(data.retval.data[i]);
								}
								$scope.pages = Math.ceil(data.retval.total
										/ $scope.limit);
								$scope.busy = false;
								if ($scope.pages <= $scope.currentPage) {
									$scope.alerts = [ {
										type : 'success',
										msg : '没有更多内容了'
									} ]
								}
							}
						});
			}
		};
		
		
		$scope.play = function(s){
			try{
				var vp=$scope.list[s.$index].voice_path;
				if(vp!=null&&vp!=''){
					//播放音频 m 即为音频地址
					if($rootScope.media!=undefined&&$rootScope.media!=null){
						$scope.list[s.$index].playm="video.png";
						$rootScope.media.release();
						/*
						$rootScope.media.stop();
						if(n.fromuser==$scope.m.user_id){
							$scope.queue[$scope.sindex].playm="yellow_video.png";
						}
						else{
							$scope.queue[$scope.sindex].playf="write_video.png";
						}
						console.log('replay png');
						console.log($scope.queue[$scope.sindex].playm);
						console.log($scope.queue[$scope.sindex].playf);
						$rootScope.media.src=$rootScope.site+n.msg;
						console.log('replay');
						console.log($rootScope.media.src);
						$scope.sindex=s.$index;
						if(n.fromuser==$scope.m.user_id){
							$scope.queue[$scope.sindex].playm="yellow_d.gif";
						}
						else{
							$scope.queue[$scope.sindex].playf="write_d.gif";
						}
						console.log('replay gif');
						console.log($scope.queue[$scope.sindex].playm);
						console.log($scope.queue[$scope.sindex].playf);
						$rootScope.media.play();*/
					}
					//else
					{

						$rootScope.media=audioplay($rootScope.site+vp);
						console.log('newplay');
						console.log($rootScope.media.src);
						$rootScope.media.successCallback=function(){
							$scope.list[s.$index].playm="video.png";
							console.log('successCallback png');
							console.log($scope.list[s.$index].playm);
							$scope.$apply();
						};
						$rootScope.media.errorCallback=function(err){
							$scope.list[s.$index].playm="video.png";
							console.log('successCallback png');
							console.log($scope.list[s.$index].playm);
							$scope.$apply();
						};

						$scope.list[s.$index].playm="write_d.gif";
						console.log('newplay png');
						console.log($scope.list[s.$index].playm);
						$rootScope.media.play();
					}
				}
			}
			catch(e){
				console.log('play');
				console.log(e);
			}
		}
		
		$scope.playe = function(s){
			try{
				var vp=$scope.list[s.$index].evaluation_voice;
				if(vp!=null&&vp!=''){
					//播放音频 m 即为音频地址
					if($rootScope.media!=undefined&&$rootScope.media!=null){
						$scope.list[s.$index].playme="video.png";
						$rootScope.media.release();
					}
					//else
					{
						$rootScope.media=audioplay($rootScope.site+vp);
						$rootScope.media.successCallback=function(){
							$scope.list[s.$index].playme="video.png";
							
							$scope.$apply();
						};
						$rootScope.media.errorCallback=function(err){
							$scope.list[s.$index].playme="video.png";
							
							$scope.$apply();
						};

						$scope.list[s.$index].playme="write_d.gif";
						$rootScope.media.play();
					}
				}
			}
			catch(e){
				console.log('play');
				console.log(e);
			}
		}
	}
	catch (e) {
		showcatch(e);
	}
});
TutorStudentEvaYzx.TutorStudentEvaYzxData=function($q, $http,$stateParams,$rootScope){
	try {
		var data = [];
		var def = $q.defer();
		if(window.localStorage.u==undefined||window.localStorage.u==null||window.localStorage.u==""){			
			$rootScope.go("loginmain");
		}else{
			def.resolve(data);
		}
		
		return def.promise;
	} catch (e) {
		showcatch(e);
	}
}